import com.sun.javafx.scene.control.skin.LabeledSkinBase;
import org.junit.Test;

import java.util.Scanner;

/**
 * @author zhangmengxiang1@itcast.cn
 * @version 1.0
 * @date 2020/4/21
 */
public class a {
    public static void main(String[] args) {
        Scanner scanner = new Scanner(System.in);
        System.out.println("请输入a的值：");
        int a = scanner.nextInt();
        System.out.println("请输入k的值：");
        int k = scanner.nextInt();
        System.out.println("请输入n的值：");
        int n = scanner.nextInt();
        double b = 0;
        int i = 1;
        int t = 0;
        String sb =  a + "";
        while (!(i > n)){
            String substring = sb.substring(sb.length()-i, sb.length()).substring(0,1);
            t = Integer.parseInt(substring);
            b = b + t*Math.pow(k,i-1);
            i = i+1;
        }
        System.out.println("b的值为：" + b);
        scanner.close();
    }

    @Test
    public void run1(){
        long start = System.currentTimeMillis();
        System.out.println(start);
    }


    @Test
    public void run2(){
        String sb = "1234";
        int i =3;
       // System.out.println(sb.substring(sb.length()-1, i));
        //                                    4 -2        4
        System.out.println(sb.substring(sb.length()-i, sb.length()).substring(0,1));

    }

}
